﻿<%@ Page Language="C#" MasterPageFile="~/Admin/AdminMasterPage.master" AutoEventWireup="true"
    CodeFile="ViewUserViewedHistory.aspx.cs" Inherits="Admin_user_ViewUserViewedHistory"
    MaintainScrollPositionOnPostback="true" Title="Admin - View User Viewed History" %>

<%@ Register Src="../../controls/usrDate.ascx" TagName="usrDate" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="contents">
        <table width="100%" cellpadding="3" cellspacing="0" border="0">
            <tr>
                <td colspan="2">
                    <h1>
                        User Viewed History<asp:Label ID="Label1" runat="server" Visible="false" Width="10px"></asp:Label>
                    </h1>
                </td>
            </tr>
            <tr>
                <td style="width: 30%"; valign="top">
                    Login Date
                </td>
                <td>
                    <asp:TextBox ID="txtDateTime" runat="server"></asp:TextBox>
                    (yyyymmdd)<%--<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
                        ValidationExpression="\d{8}" ControlToValidate="txtDateTime" ErrorMessage="8 digits number format only."></asp:RegularExpressionValidator>--%>
                </td>
            </tr>
            <tr>
                <td valign="top">
                    Page Type
                </td>
                <td>
                    <asp:DropDownList runat="server" ID="ddlPageType">
                        <asp:ListItem Value="ALL" Text="ALL"></asp:ListItem>
                        <asp:ListItem Value="CX" Text="Security"></asp:ListItem>
                        <asp:ListItem Value="USR" Text="User Login/Register"></asp:ListItem>
                        <asp:ListItem Value="UFB" Text="User Feedback"></asp:ListItem>
                        <asp:ListItem Value="URH" Text="User Quotes/Result History"></asp:ListItem>
                        <asp:ListItem Value="HP" Text="Home Page"></asp:ListItem>
                        <asp:ListItem Value="PWR" Text="Password Recovery"></asp:ListItem>
                        <asp:ListItem Value="SIR" Text="Set Insurance Reminder"></asp:ListItem>
                        <asp:ListItem Value="CTUS" Text="Contact Us"></asp:ListItem>
                        <asp:ListItem Value="404" Text="Page Not Found"></asp:ListItem>
                        <asp:ListItem Value="403" Text="Page Forbidden"></asp:ListItem>
                        <asp:ListItem Value="CI" Text="Car Insurance"></asp:ListItem>
                        <asp:ListItem Value="HF" Text="Home Refinance"></asp:ListItem>
                        <asp:ListItem Value="PL" Text="Personal Loan"></asp:ListItem>
                        <asp:ListItem Value="PA" Text="Personal Accident"></asp:ListItem>
                        <asp:ListItem Value="CC" Text="Credit Card"></asp:ListItem>
                        <asp:ListItem Value="TA" Text="Travel Insurance"></asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;
                </td>
                <td>
                    <asp:Button ID="btnShowResult" runat="server" OnClick="btnShowResult_Click" Text="Submit" />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <h2>Result</h2>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:GridView ID="grvViewHistory" runat="server" AutoGenerateColumns="False" Cellspacing="3" CellPadding="3" Width="100%"
                        DataKeyNames="ViewedId" DataSourceID="sqlDbUserViewedHistory" CssClass="admin_gridstyle" PagerStyle-CssClass="pgr"
                        GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnRowCreated="grvLoginHistory_RowCreated"
                        OnRowDataBound="grvLoginHistory_RowDataBound">
                        <Columns>
                            <%-- <asp:BoundField DataField="BrowserInfo" HeaderText="BrowserInfo" 
                                SortExpression="BrowserInfo" />--%>
                            <asp:BoundField DataField="ViewedId" HeaderText="ViewedId" InsertVisible="False"
                                ReadOnly="True" SortExpression="ViewedId" />
                            <asp:BoundField DataField="IpNumber" HeaderText="IpNumber" SortExpression="IpNumber" />
                            <asp:BoundField DataField="PageType" HeaderText="PageType" SortExpression="PageType" />
                            <asp:BoundField DataField="BrowserType" HeaderText="BrowserType" SortExpression="BrowserType" />
                            <asp:HyperLinkField HeaderText="BrowserInfo" Text="Browser Info" Target="_blank"
                                DataNavigateUrlFormatString="ViewUserBrowserInfo.aspx?ViewedId={0}" DataNavigateUrlFields="ViewedId">
                            </asp:HyperLinkField>
                            <asp:BoundField DataField="ViewedCount" HeaderText="ViewedCount" SortExpression="ViewedCount" />
                            <asp:BoundField DataField="ViewedDate" HeaderText="ViewedDate" SortExpression="ViewedDate" />
                            <asp:CommandField ShowSelectButton="True" SelectText="View Details" />
                        </Columns>
                        <FooterStyle />
                        <PagerStyle />
                        <SelectedRowStyle />
                        <HeaderStyle CssClass="admin_gridheader" />
                        <EditRowStyle />
                        <AlternatingRowStyle CssClass="admin_gridodd" />
                        <RowStyle CssClass="admin_grideven" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="sqlDbUserViewedHistory" runat="server" ConnectionString="<%$ ConnectionStrings:TH.CX_DBConnectionString %>"
                        SelectCommand="sprocUserViewedHistorySelectItemListByViewedDatePageType" SelectCommandType="StoredProcedure">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="txtDateTime" Name="ViewedDate" PropertyName="Text"
                                Type="String" />
                            <asp:ControlParameter ControlID="ddlPageType" Name="PageType" PropertyName="SelectedValue"
                                Type="String" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <h2>Details</h2>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:GridView ID="grvViewHistoryDetail" runat="server" AutoGenerateColumns="False"
                        Cellspacing="3" CellPadding="3" Width="100%" DataKeyNames="ViewedID,ViewedNo" DataSourceID="sqlDbUserViewedDetail"
                        CssClass="admin_gridstyle" PagerStyle-CssClass="pgr" GridLines="None" OnRowCreated="grvLoginHistory_RowCreated"
                        OnRowDataBound="grvLoginHistory_RowDataBound" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
                        <Columns>
                            <asp:BoundField DataField="ViewedDetailId" HeaderText="ViewedDetailId" InsertVisible="False"
                                ReadOnly="True" SortExpression="ViewedDetailId" />
                            <asp:BoundField DataField="ViewedId" HeaderText="ViewedId" SortExpression="ViewedId" />
                            <asp:BoundField DataField="ViewedNo" HeaderText="ViewedNo" SortExpression="ViewedNo" />
                            <asp:BoundField DataField="ViewedDescription" HeaderText="ViewedDescription" SortExpression="ViewedDescription" />
                            <asp:BoundField DataField="CreatedDate" HeaderText="CreatedDate" SortExpression="CreatedDate" />
                        </Columns>
                        <FooterStyle />
                        <PagerStyle />
                        <SelectedRowStyle />
                        <HeaderStyle CssClass="admin_gridheader" />
                        <EditRowStyle />
                        <AlternatingRowStyle CssClass="admin_gridodd" />
                        <RowStyle CssClass="admin_grideven" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="sqlDbUserViewedDetail" runat="server" ConnectionString="<%$ ConnectionStrings:TH.CX_DBConnectionString %>"
                        SelectCommand="sprocUserViewedHistoryDetailSelectItemListByViewedID" SelectCommandType="StoredProcedure">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="grvViewHistory" Name="ViewedID" PropertyName="SelectedValue"
                                Type="Int64" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <h2>Selected Result Item</h2>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:GridView ID="grvViewSelectedHistory" runat="server" AutoGenerateColumns="False"
                        Cellspacing="3" CellPadding="3" Width="100%" DataKeyNames="SelectedId" DataSourceID="sqlDbUserSelected" CssClass="admin_gridstyle" PagerStyle-CssClass="pgr"
                        GridLines="None" OnRowCreated="grvLoginHistory_RowCreated" OnRowDataBound="grvLoginHistory_RowDataBound"
                        OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
                        <Columns>
                            <asp:BoundField DataField="SelectedId" HeaderText="SelectedId" InsertVisible="False"
                                ReadOnly="True" SortExpression="SelectedId" />
                            <asp:BoundField DataField="SelectedType" HeaderText="SelectedType" SortExpression="SelectedType" />
                            <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName" />
                            <asp:BoundField DataField="SelectedResultId" HeaderText="SelectedResultId" SortExpression="SelectedResultId" />
                            <asp:BoundField DataField="SelectedCount" HeaderText="SelectedCount" SortExpression="SelectedCount" />
                            <asp:BoundField DataField="SelectedDate" HeaderText="SelectedDate" SortExpression="SelectedDate" />
                            <asp:HyperLinkField HeaderText="" Text="Viewed Details" Target="_blank"
                                DataNavigateUrlFormatString="ViewUserResultSelectedItemInfo.aspx?SelectedID={0}&SelectedType={1}" DataNavigateUrlFields="SelectedId,SelectedType">
                            </asp:HyperLinkField>
                        </Columns>
                        <FooterStyle />
                        <PagerStyle />
                        <SelectedRowStyle />
                        <HeaderStyle CssClass="admin_gridheader" />
                        <EditRowStyle />
                        <AlternatingRowStyle CssClass="admin_gridodd" />
                        <RowStyle CssClass="admin_grideven" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="sqlDbUserSelected" runat="server" ConnectionString="<%$ ConnectionStrings:TH.CX_DBConnectionString %>"
                        SelectCommand="sprocUserSelectededHistoryDetailSelectItemListByViewedID" SelectCommandType="StoredProcedure">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="grvViewHistory" Name="ViewedID" PropertyName="SelectedValue"
                                Type="Int64" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
